

CREATE TABLE GOODS
(
       gid     NUMBER(10) primary key,
       gname   VARCHAR2(20) NOT NULL UNIQUE,
       gprice  NUMBER(18,2) NOT NULL,
       gnum    NUMBER(11) NOT NULL
);


 


CREATE SEQUENCE goods_seq  
       START WITH    1
       INCREMENT  BY 1
       MINVALUE      1
       MAXVALUE   100000 
       NOCYCLE          
       CACHE 10;         
       
       



CREATE TRIGGER goods_trigger
       BEFORE INSERT ON goods
       FOR EACH ROW       
       BEGIN               
           SELECT goods_seq.nextval INTO :new.gid FROM dual;
       END;



